package Demo01;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        int[] arr = {2,7,11,15};
        Solution solution = new Solution();
        System.out.println(Arrays.toString(solution.twoSum(arr, 9)));
    }
}
class Solution {
    public int[] twoSum(int[] nums, int target) {
        HashMap<Integer,Integer> hashMap = new HashMap();
        int[] arr = new int[2];
        for (int i = 0; i < nums.length; i++) {
            if(hashMap.size()!=0&&hashMap.containsKey(target-nums[i])) {
                arr[0] = i;
                arr[1] = hashMap.get(target-nums[i]);
                break;
            }
            hashMap.put(nums[i],i);
        }
        return arr;
    }
}


// 注意类名必须为 Main, 不要有任何 package xxx 信息
class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int a = in.nextInt();
            int b = in.nextInt();
            System.out.println(a + b);
        }
    }
}